<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>设置</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <style>
        body {
            background: #f3f3f3;
            /*font-size: 14px;*/
        }
        .aui-pull-right {
            color: #666;font-size: 14px;
        }
        .exit{
            text-align: center;
            color: red;
        }
    </style>
</head>
<body>
<header class="aui-bar aui-bar-nav aui-border-b" style="margin-bottom: 15px;">
    <div class="aui-pull-left aui-iconfont aui-icon-left icon-left-coler" tapmode onclick="closeWin()"></div>
    <div class="aui-title">设置</div>
</header>

<div class="contain">
    <ul class="aui-list-view">
        <li class="aui-list-view-cell" tapmode onclick="openToTwo('changePwd')">
            <a class="aui-arrow-right">
                <span class="text">修改登录密码</span>
            </a>
        </li>
    </ul>

    <ul class="aui-list-view">
        <li class="aui-list-view-cell" tapmode>
            <span class="text">当前版本</span>
            <span class="aui-pull-right" id="appVersion">0</span>
        </li>
    </ul>

    <ul class="aui-list-view">
        <li class="aui-list-view-cell" tapmode onclick="clearCache()">
            <span class="text">清除缓存</span>
            <span class="aui-pull-right" id="cacheSize">0.00M</span>
        </li>
    </ul>

    <ul class="aui-list-view">
        <li class="aui-list-view-cell exit" tapmode onclick="exit()">
            退  出
        </li>
    </ul>
</div>
<!--<footer class="aui-nav">-->

<!--<ul>-->
<!--<li>-->
<!--<div class="myBtn cancel" tapmode onclick="hidePicker()">取消</div>-->
<!--<div class="myBtn  confirm" tapmode onclick="setAttr(this)">保存</div>-->
<!--</li>-->
<!--</ul>-->
<!--</footer>-->

<div class="aui-dialog aui-hidden" id="dialog">
    <div class="aui-dialog-header">确定要退出登录吗？</div>
    <div class="aui-dialog-body aui-text-center">
        本地信息和聊天数据将被清空
    </div>
    <div class="aui-dialog-footer">
        <div class="aui-dialog-btn aui-text-danger" tapmode onclick="cancel()">取消</div>
        <div class="aui-dialog-btn aui-text-info" tapmode onclick="confirm()">确定</div>
    </div>
</div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>
<!-- <script type="text/javascript" src="../script/mui.js"></script> -->
<script type="text/javascript">
    apiready = function () {
        api.parseTapmode();
        var mobile = api.pageParam.mobile;
        var header = $api.dom('header');
        var footer = $api.dom('footer');
        $api.fixIos7Bar(header);

        //获取版本号
        getAppVersion();
        //获取缓存大小
        getCacheSize();
    }

    //获取版本号
    function getAppVersion(){
        var appVersion = api.appVersion;
        $('#appVersion').text(appVersion);
    }

    //清除缓存
    function clearCache() {
        showLoading();
        api.clearCache(function () {
            api.toast({
                msg: '清除完成'
            });
        });
        $('#cacheSize').text('0.00M');
        hideLoading();
    }

    //获取缓存数据大小
    function getCacheSize(){
        var size = api.getCacheSize({
            sync: true
        });
        size = size / 1024 / 1024;
        size = size.toFixed(2);
        $('#cacheSize').text(size + 'M');
    }

    function exit(){
        $api.append($api.dom("body"),'<div class="aui-mask"></div>');
        $api.removeCls($api.dom(".aui-dialog.aui-hidden"),"aui-hidden");
        api.sendEvent({
            name: 'dialogEvent',
            extra: {type:'show'}
        });
    }

    function cancel(){
        $api.remove($api.dom(".aui-mask"));
        $api.addCls($api.dom(".aui-dialog"),"aui-hidden");
        api.sendEvent({
            name: 'dialogEvent',
            extra: {type:'hidden'}
        });
    }

    function confirm(){
        $api.clearStorage();
        //发送退出监听
        api.sendEvent({
            name:"loginOut",
            extra:{
                loginOut:true
            }
        })
        api.closeToWin({
            name:"root"
        })
    }
</script>
</html>
